//ConfigurationSingleton.java
import java.io.*;
import java.util.*;

public class ConfigurationSingleton implements java.io.Serializable {

    //private static ConfigurationSingleton ref;
    private LinkedList scanDirectories;
    private LinkedList deletedFiles;
    private int updateInterval;
    private String homeDirName;
    private Hashtable launchAppTable = new Hashtable();
    private boolean hideMaskedFiles = false;

  public ConfigurationSingleton()
  {
    updateInterval = 5000;
    scanDirectories = new LinkedList();
    deletedFiles = new LinkedList();

    homeDirName = System.getProperty("dbfs.home.dir");
    if (homeDirName==null)
      System.out.println("System property 'dbfs.home.dir' not available");

    File homeDir = new File(homeDirName);
    if (!homeDir.exists() || !homeDir.isDirectory())
      System.out.println("Home directory " + homeDir.getPath() + " does not exist or is not a directory");
  }

  //public static ConfigurationSingleton getConfigurationSingleton()
  // {
  //  if (ref == null)
  //      ref = new ConfigurationSingleton();
  //  return ref;
  //}

  public void seeMaskedFiles(){
     hideMaskedFiles = false;
     FileBrowserGUI.hideMaskedFiles = false;
  }

  public void hideMaskedFiles(){
       hideMaskedFiles = true;
       FileBrowserGUI.hideMaskedFiles = true;
  }

  public boolean masked(){
     return hideMaskedFiles;
  }

  public void setUpdateInterval(int time){
     updateInterval = time;
  }

  public void setLaunchApp(String extension,String app){
     launchAppTable.put(extension,app);
     System.out.println(extension+" "+(String)launchAppTable.get(extension));
  }

  public String getLaunchApp(String extension){
     return (String)launchAppTable.get(extension);
  }

  public int getUpdateInterval(){
     return updateInterval;
  }

  public String getHomedir(){
     return homeDirName;
  }

  public void clearScanDirectories(){
     scanDirectories.clear();
  }

  public void addScanDirectory(File file){
     scanDirectories.add(file);
  }

  public void addScanDirectories(File[] files){
     for(int i=0;i<files.length;i++){
        scanDirectories.add((File)files[i]);
     }
  }

  public LinkedList getScanDirectories(){
     return scanDirectories;
  }

  public LinkedList getDeletedFiles(){
      return deletedFiles;
  }

  public void addDeletedFile(DBFile db){
     deletedFiles.add(db);
  }
  public void clearDeletedFiles(){
     deletedFiles.clear();
  }
     //public Object clone()
  // throws CloneNotSupportedException
  //{
  //  //we want to overirde Object's clone method to not support clonning thus insuring a singleton
  //  throw new CloneNotSupportedException();
  // }

}